#!/bin/bash
# creates mpeg movies for successive images listed as arguments
# currently, only two images are used to make each movie (i.e. a movie has two frames)
# 
# arguments:
#
# required libraries:
#       imagemagick -- for convert function
#       mpeg2enc    -- used by imagemagick to create mpegs

echo "usage: make_movies.sh <quality> <images>"
q=$1
shift
while (("$#" > 1))
do
    convert -quality $q ${1} ${2} ${1%.*}_${2%.*}.mpg
    convert -quality $q ${2} ${1} ${2%.*}_${1%.*}.mpg
    convert -quality $q ${1} ${1} ${1%.*}_${1%.*}.mpg
    convert -quality $q ${1} ${1%.*}.mpg
    shift
done
if (("$#" > 0))
then
    convert -quality $q ${1} ${1} ${1%.*}_${1%.*}.mpg
    convert -quality $q ${1} ${1%.*}.mpg
fi

